package com.dengkeng.blog.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@RestController
public class DemoController {

    static List<String> ips = new ArrayList<>();

    @GetMapping("/hello")
    public String hello() {
        return "hello2222";
    }

    @GetMapping("/ip")
    public String ip(HttpServletRequest request) {
        ips.add(request.getRemoteHost() + "----" + new Date());
        return request.getRemoteHost();
    }

    @GetMapping("/ips")
    public String ips(HttpServletRequest request) {
        return ips.toString();
    }


}
